--local Button = require('src/Widgets/Button')
--local Class = require('leviathan/Class')
local Color = require('libs/colorlibrary/colorlibrary')
local Core = require('src/Core')
--local Event = require('src/Event')
local Graphics = require('src/graphics')
local i18n = require('libs/i18n')
local Label = require('src/Widgets/Label')
local Log = require('src/Log')
local Picture = require('src/Widgets/Picture')
local Snow = require('libs/love-snowflakes/snow')
local State = require('src/State')
local Tween = require('libs/tween/tween')
local Widget = require('src/Widgets/Widget')

local locationState = State:derive('Screen')

function locationState:new(name)
    Log:info('Creating new location: '..name)
--    locationState.super.new(self)
    self.name = name
    local s = base.locations[name]
    -- get data
    self.music = s.music
    self.musicVolume = s.musicVolume
    if self.musicVolume == nil then
        self.musicVolume = 1
    end
    self.map = s.map
    -- screen dimensions
    local sw, sh = love.window.getMode()

    self.status = 'created'
end

function locationState:load()
--    ENGINE.SM:switch('FadeState', 'fadein', true)
    ENGINE.SM:InitState('MapState', self.name)
--    ENGINE.SM:Switch('MapState', self.name, nil)
--    local s = ENGINE.SM:GetTopState()
--    s.map = self.map
    ENGINE.SM:Switch('MapState', true)
    -- events
--    ENGINE.EVENTS:hook('key_pressed', self.skipScreen)
end

function locationState:update(dt)
-- self.cover:update(dt)
--    local t = love.timer.getTime()
--   print(t, self.timeStart, self.duration)
end

function locationState:draw()
    -- draw background
    love.graphics.setColor(1, 1, 1, 0.5)
    love.graphics.rectangle('fill', 0, 0, love.graphics.getWidth(), love.graphics.getHeight())
--    self.bg:draw()
--    self.label:draw()
    Graphics:ShowFPS()
end


function locationState:exit()
--    ENGINE.EVENTS:unhook('key_pressed', self.skipScreen)
--    ENGINE.EVENTS:remove('key_pressed')
end

-- ----------

return locationState
